home *** CD-ROM | disk | FTP | other *** search
/ The Best of Tucows 3 / The Best of Tucows 3 - Disc 1.iso / content / win95 / files / mainst.exe / _setup.lib / Setup.rul < prev    next >
Text File  |  1997-02-09  |  12KB  |  350 lines

  1. /*----------------------------------------------------------------------------*\
  2.  *
  3.  *  IIIIIII SSSSSS
  4.  *    II    SS                          InstallShield (R)
  5.  *    II    SSSSSS          (c) 1990-1996, Stirling Technologies, Inc.
  6.  *    II        SS                     All Rights Reserved.
  7.  *  IIIIIII SSSSSS
  8.  *
  9.  *
  10.  *    File Name:  SETUP.RUL
  11.  *
  12.  *  Description:  InstallShield Professional Edition
  13.  *                32-bit script.
  14.  *
  15.  *
  16.  *       Author:  Diamond Ridge, Inc.           Date: 2-8-97
  17.  *
  18.  *     Comments:  
  19.  *
  20.  *
  21.  *
  22. \*----------------------------------------------------------------------------*/
  23.  
  24. declare
  25.  
  26. // Constant declarations.
  27. #define SPACE_REQUIRED          4500000          // Disk space in bytes.
  28. #define APP_NAME                "CRADAbase"
  29. #define PROGRAM_FOLDER_NAME     "CRADAbase"
  30. #define APPBASE_PATH            "CRADAbase\\"
  31. #define APPBASE_PATH_WIN32S     "CRADAbase\\"
  32. #define COMPANY_NAME            "Diamond Ridge, Inc."
  33. #define PRODUCT_NAME            "CRADAbase"
  34. #define PRODUCT_VERSION         "1.0"
  35. #define DEINSTALL_KEY           "CRADAbase"
  36. #define UNINSTALL_NAME          "CRADAbase"
  37. #define PRODUCT_KEY             "tucars.exe"
  38.  
  39.         // Global variable declarations.
  40.         STRING  svFolder, svDir, szMsg, szFileSet, szTitle, svUninstLogFile;
  41.         STRING  svTarget, szProgram, szParam, szTemp, szAppPath, svSite, svDUMName;
  42.         BOOL    bSpaceOk, bWinNT, bWin32s, bIsShellExplorer;
  43.         NUMBER  nResult;
  44.     #include "sddialog.h"
  45.  
  46.         // Function declarations.
  47.         prototype SetupScreen();
  48.         prototype CheckRequirements();
  49.  
  50. program
  51.  
  52. StartHere:
  53.         Disable( BACKGROUND );
  54.  
  55.         // Set installation info., which is required for registry entries.
  56.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  57.  
  58.         // Set up thr installation screen.
  59.         SetupScreen();
  60.         Enable( DIALOGCACHE );
  61.  
  62.  
  63.    // Create a Welcome dialog.
  64.    WelcomeDlg:
  65.         Disable( BACKBUTTON );
  66.         Welcome( "", 0 );
  67.         Enable( BACKBUTTON );
  68.  
  69.         // Test target system for proper configuration.
  70.         CheckRequirements();
  71.  
  72.  
  73.    // Ask user for a destination location for the installation.--
  74.    GetTargetDirectory:
  75.         if (bWin32s) then
  76.            svTarget = TARGETDISK ^ APPBASE_PATH_WIN32S;
  77.         else
  78.            svTarget = TARGETDISK ^ APPBASE_PATH;
  79.         endif;
  80.         if ( AskDestPath( "", szMsg,
  81.                           svTarget, 0 ) = 12 ) then
  82.            goto WelcomeDlg;
  83.         endif;
  84.  
  85.         // Perform space check of target drive.
  86.         bSpaceOk = TRUE;
  87.         if (GetDiskSpace( svTarget ) < SPACE_REQUIRED) then
  88.            szMsg = "There is not enough space available on the disk\n" +
  89.                    "'" + svTarget + "' \n" +
  90.                    "Please free up some space or change the target location\n" +
  91.                    "to a different disk";
  92.            MessageBox( szMsg, WARNING );
  93.            bSpaceOk = FALSE;
  94.         endif;
  95.  
  96.          // If not enough space, ask user to try again.
  97.         if (bSpaceOk = FALSE) goto GetTargetDirectory;
  98.  
  99.         // Set the App Paths key for the main program.
  100.         szAppPath = svTarget ^ "PROGRAM";
  101.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  102.         szProgram = svTarget ^ "PROGRAM\\tucars.exe";
  103.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  104.  
  105.    // Ask user for Site Code for database replication.
  106.    GetSite:
  107.     SetDialogTitle(DLG_ASK_TEXT, "Enter Site Code");
  108.     if (AskText("Please enter the Site Code (used for database replication)","",svSite) = 12) then
  109.        goto GetTargetDirectory;
  110.         endif;
  111.     if (svSite = "") goto GetSite;
  112.  
  113.    SetupFilesToTransfer:
  114.         szFileSet = "General";
  115.         TARGETDIR = svTarget;
  116.  
  117.         // Define the file set.
  118.         FileSetBeginDefine( szFileSet );
  119.  
  120.            SetStatusWindow( -1, "Copying program files..." );
  121.            CompressGet( "DATA.Z", "program\\*.*", INCLUDE_SUBDIR );
  122.  
  123.            SetStatusWindow( -1, "Copying TWAIN drivers..." );
  124.        TARGETDIR = WINDIR;
  125.            CompressGet( "DATA.Z", "twain\\*.*", INCLUDE_SUBDIR );
  126.  
  127.            SetStatusWindow( -1, "Copying system files..." );
  128.            TARGETDIR = WINSYSDIR;
  129.            CompressGet( "DATA.Z", "winsys\\*.*", INCLUDE_SUBDIR );
  130.  
  131.         FileSetEndDefine( szFileSet );
  132.  
  133.  
  134.    TransferFiles:
  135.         // Prepare InstallShield to record deinstallation information.
  136.         DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  137.         RegDBSetItem( REGDB_UNINSTALL_NAME, UNINSTALL_NAME );
  138.  
  139.         // Set up progress indicator and information gauge.
  140.         Disable( DIALOGCACHE );
  141.         Enable( STATUSDLG );
  142.  
  143.         StatusUpdate( ON, 90 );
  144.  
  145.         // Perform the file set.
  146.         SetStatusWindow( 0, "Copying program files..." );
  147.         nResult = FileSetPerformEz( szFileSet, 0 );
  148.  
  149.         switch (nResult)
  150.  
  151.         case FS_DONE: // Successful completion.
  152.  
  153.         case FS_CREATEDIR: // Create directory error.
  154.              MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
  155.                          "Please check write access to this directory.", SEVERE );
  156.              exit;
  157.  
  158.         default: // Group all other errors under default label.
  159.              NumToStr( szTemp, nResult );
  160.              MessageBox( "General file transfer error."+
  161.                           "Please check your target location and try again."+
  162.                           "\n\n Error Number:"+szTemp +
  163.                           "\n Related File: "+ERRORFILENAME,
  164.                           SEVERE );
  165.              exit;
  166.         endswitch;
  167.  
  168.         Delay( 1 );
  169.  
  170. //      Create app subdirectories
  171.         CreateDir(svTarget ^ "Database");
  172.         CreateDir(svTarget ^ "Pictures");
  173.         CreateDir(svTarget ^ "Reports");
  174.         CreateDir(svTarget ^ "Repl");
  175.         CreateDir(svTarget ^ "Repl\\Crada");
  176.         CreateDir(svTarget ^ "Repl\\" + svSite);
  177.  
  178. //      Modify Autoexec.bat
  179.         SetStatusWindow( -1, "Modifying startup files..." );
  180.     BatchFileLoad("");
  181.     BatchDeleteEx("SQLREMOTE",0);
  182.     BatchAdd("SQLREMOTE", svTarget ^ "REPL", "PATH", AFTER);
  183.     BatchFileSave("");
  184.  
  185. //    Modify site-specific info in CRADA.INI
  186.         LongPathToShortPath(svTarget);
  187.     WriteProfString(WINDIR ^ "CRADA.INI", "Account Information", "Site", svSite);
  188.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Database", svTarget ^ "Database");
  189.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Logo", svTarget ^ "Crada.bmp");
  190.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "LocalPictures", svTarget ^ "Pictures");
  191.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Reports", svTarget ^ "Reports");
  192.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "TUTransactionDir", "Crada");
  193.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "DealerTransactionFiles", svSite + "\\*.*");
  194.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "LocalDealerTransactionDir", svTarget ^ "Repl" ^ svSite);
  195.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "LocalTUTransactionFiles", svTarget ^ "Repl\\Crada\\*.*");
  196.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "FtpFromTUScript", "c:\\ftptu.txt");
  197.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "IP", "ftp.etu.com");
  198.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "FtpToTUScript", "c:\\ftp2tu.txt");
  199.     WriteProfString(WINDIR ^ "CRADA.INI", "TUADS Car Scheduling", "Program", svTarget ^ svDUMName);
  200.  
  201.    // Create program folders and icons.
  202.    InstallProgramItems:
  203.         SetStatusWindow( 95, "Creating Program Folder and Icons...." );
  204.  
  205.         AppCommand( PROGMAN, CMD_RESTORE );
  206.         svFolder = PROGRAM_FOLDER_NAME;
  207.         CreateProgramFolder( svFolder );
  208.         ShowProgramFolder( svFolder, 0 );
  209.         LongPathToShortPath( svTarget );
  210.         Delay(1);
  211.  
  212.         szProgram = svTarget ^ "TUCARS.EXE";
  213.            AddFolderIcon( svFolder, APP_NAME, szProgram,
  214.                           svTarget,
  215.                           "", 0, "", REPLACE );
  216.